 /* 
 * File:   cTank.h
 * Author: josep
 *
 * Created on 28 / desembre / 2010, 22:53
 */

#ifndef CTANK_H
#define	CTANK_H

#include "cBackgroundScene.h"


#include "cAutonomousAgent.h"
#include "cCollisionEvent.h"
#include "cBullet.h"


class cTank: public cAutonomousAgent {
public:
    enum Estado {OFF=0, MOVING_LEFT=1, MOVING_RIGHT=2, SHOOTING_LEFT=3,
                                        SHOOTING_RIGHT=4, BURNING_LEFT=5,
                                        BURNING_RIGHT=6, DEATH=7};
    enum Transition {STOP=0, TO_LEFT, TO_RIGHT, GO_AHEAD, SHOOT, REACHED, DIE};
    cTank();
    cTank(const cTank& orig);
    virtual ~cTank();
    virtual void Init(cTexture *texture, int PosX=0, int PosY=0, int Width=0,
                                int Height=0);
    virtual void NextStep(int time);
    virtual bool isDead();
    void addEnemy(int enemy);
    void removeEnemy(int enemyToRemove);
    void clearEnemies();
    void SetBulletTexture(cTexture* BulletTexture);
    cTexture* GetBulletTexture() const;
    void Shoot(cBullet* bullet);
    cPhysicalObject* popChild();
protected:
    virtual void Notify(cPhysicalReaction *reaction);
    virtual bool NotifyAgentCollision(cAgentCollisionEvent *revent);
    virtual int ChangeFramestate(int, int, int);
private:
    void localizeEnemy(vector< vector<int> >* VisibleMap);
    void Init();
    cBullet* PrepareShot(int dist);
    void approachToENenmy(int dist);
    void awayToENenmy(int dist);
    list <int> enemyPattern;
    bool localizedEnemy;
    cTexture* BulletTexture;
    int timeToFire;
    int ShotInterval;
};

#endif	/* CTANK_H */

